//
// Created by Tony on 2024/7/9.
//

#ifndef RT_CODE_SYM_REF_H
#define RT_CODE_SYM_REF_H

#include <cstdint>
#include <memory>

namespace RtCode {

using std::shared_ptr;
using std::string;
using std::weak_ptr;
class ConstantPool;
class Class;

class SymRef {
    uint16_t classNameIndex;

    weak_ptr<ConstantPool> mConstantPool; // 使用此SymRef的类的常量池
    weak_ptr<Class> mClass;               // 定义此Sym的类

public:
    SymRef(const shared_ptr<ConstantPool>& constantPool, uint16_t nameIndex)
        : mConstantPool(constantPool), classNameIndex(nameIndex) {}

    uint16_t getClassNameIndex() const;
    string className() const;
    shared_ptr<ConstantPool> getConstantPool() const;
    shared_ptr<Class> resolvedClass();
};

} // namespace RtCode

#endif // RT_CODE_SYM_REF_H
